package br.com.site.fiolaser.util;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

public class IntegerConverter implements Converter{  

	public Object getAsObject(FacesContext arg0, UIComponent arg1, String valor) throws ConverterException {  
		if(valor == null || valor.toString().trim().equals("")){  
			return null;  

		} else {  
			return Integer.parseInt(valor);  
		}  

	}        


	public String getAsString(FacesContext arg0, UIComponent arg1, Object valor) throws ConverterException {  

		if(valor == null || valor.toString().trim().equals("")){  
			return "";  

		} else {  
			return valor.toString();   
		}  
	}   

}  